﻿using System;
using NUnit.Framework;
using ProjetoComperio.Framework.Util;

namespace ProjetoComperio.Test.ComperioFramework.Util
{
    [TestFixture]
    public class StringExtensionTest
    {
        #region ParseableToDateTime
        [Test]
        public void TestIsParseableToDateTimeValidValue()
        {
            Assert.IsTrue(DateTime.Now.ToString().IsParseableToDateTime());
        }
        [Test]
        public void TestIsParseableToDateTimeInvaliddValue()
        {
            Assert.IsFalse("a10/10/2010".IsParseableToDateTime());
        }
        #endregion

        #region ParseableToBoolean
        [Test]
        public void TestIsParseableToBooleanValidValue()
        {
            Assert.IsTrue("True".IsParseableToBoolean());
            Assert.IsTrue("False".IsParseableToBoolean());

        }

        [Test]
        public void TestIsParseableToBooleanValidUpperCaseValue()
        {
            Assert.IsTrue("TRUE".IsParseableToBoolean());
            Assert.IsTrue("FALSE".IsParseableToBoolean());

        }

        [Test]
        public void TestIsParseableToBooleanValidLowerCaseValue()
        {
            Assert.IsTrue("true".IsParseableToBoolean());
            Assert.IsTrue("false".IsParseableToBoolean());

        }
        [Test]
        public void TestIsParseableToBooleanValidVariantCaseValue()
        {
            Assert.IsTrue("TrUe".IsParseableToBoolean());
            Assert.IsTrue("FALse".IsParseableToBoolean());

        }

        [Test]
        public void TestIsParseableToBooleanOnOtherRepresentation()
        {
            Assert.IsTrue("on".IsParseableToBoolean());
            Assert.IsTrue("off".IsParseableToBoolean());


        }
        [Test]
        public void TestIsParseableToBooleanOtherRepresentationUpperCase()
        {
            Assert.IsTrue("ON".IsParseableToBoolean());
            Assert.IsTrue("OFF".IsParseableToBoolean());

        }
        [Test]
        public void TestIsParseableToBooleanOtherRepresentationLowerCase()
        {
            Assert.IsTrue("on".IsParseableToBoolean());
            Assert.IsTrue("off".IsParseableToBoolean());

        }
        [Test]
        public void TestIsParseableToBooleanOtherRepresentationVariantCase()
        {
            Assert.IsTrue("On".IsParseableToBoolean());
            Assert.IsTrue("OfF".IsParseableToBoolean());

        }
        [Test]
        public void TestIsParseableToBooleanInvalidValue()
        {
            Assert.IsFalse("".IsParseableToBoolean());
            Assert.IsFalse("as1".IsParseableToBoolean());

        }
        [Test]
        public void TestIsParseableToBooleanUsingNumberAsString()
        {
            Assert.IsFalse("0".IsParseableToBoolean());
            Assert.IsFalse("1".IsParseableToBoolean());

        }
        #endregion

    }
}
